<?php 
// 1.获取数据
$vname = $_POST['vname'];
$vpwd = $_POST['password'];
$confirm = $_POST['confirm'];
$phone = $_POST['phone'];
$address = $_POST['address'];

if(!isset($vname)||!isset($vpwd)||!isset($confirm)||!isset($phone)||!isset($address)){
	exit();
}else{
	$conn = mysqli_connect('127.0.0.1','root','123456','cake2','3306');
	if($conn){
		$select = mysqli_query($conn,"SELECT * FROM user WHERE vname='$vname'");
		$res = mysqli_fetch_array($select);

		if($res['vname']!=$vname){
			mysqli_query($conn,"SET NAMES UTF8");
			$sql = "INSERT INTO user(vname,vpwd,confirm,phone,address)
			 VALUES ('$vname','$vpwd','$confirm','$phone','$address')";
			$result = mysqli_query($conn,$sql);
			if($result){
				header('location:l.php');
			}else{
				echo('注册失败！'.mysqli_error($conn));
			}
		}else{
			header('location:r.php');
		}
	}else{
		echo "注册失败！";
	}
}
?>